package com.xyzwps.ewa.modules.user

import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.encoding.*

object UserIdSerializer : KSerializer<UserId> {
    override val descriptor = PrimitiveSerialDescriptor("UserId", PrimitiveKind.LONG)

    override fun serialize(encoder: Encoder, value: UserId) {
        encoder.encodeLong(value.value)
    }

    override fun deserialize(decoder: Decoder): UserId {
        return UserId(decoder.decodeLong())
    }
}